<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//不需要登录接口
Route::group([
    'prefix' => 'admin',
], function ($router) {
    Route::any('login', 'Admin\AuthController@login')->name('login');
//    Route::any('test', 'IndexController@test2');
//    Route::any('kafkap', 'IndexController@prodcut');
//    Route::any('kafkac', 'IndexController@comsumer');
});

//公共接口：只需要登录，不需要权限分配
Route::group([
    'prefix' => 'admin',
    'middleware' => [
        'auth:api',
    ]
], function ($router) {
    //api/admin/logout
    Route::post('logout', 'Admin\AuthController@logout');
    Route::post('refresh', 'Admin\AuthController@refresh');
    Route::post('me', 'Admin\AuthController@me');

    //api/admin/getmenu
    Route::post('getmenu', 'Admin\SystemSetController@getmenu');
    //api/admin/getButtonPermissions 获取用户所有按钮权限接口
    Route::post('getButtonPermissions', 'Admin\SystemSetController@getButtonPermissions');
    Route::post('getGroupUsers', 'Admin\GroupController@getGroupUsers');

    //获取所有用户信息 用户组页面用到的接口
    Route::post('getAllUsers', 'Admin\UserController@getAllUsers');
});


//需要登录和权限验证接口
Route::group([
    'prefix' => 'admin',
    'middleware' => [
        'auth:api',
        'check.permission'
    ]
], function ($router) {

    //菜单列表数据
    Route::post('getMenuList', 'Admin\SystemSetController@getMenuList');
    //api/admin/addmenu
    Route::post('addMenu', 'Admin\SystemSetController@add');
    Route::post('editMenu', 'Admin\SystemSetController@edit');
    Route::post('setSort', 'Admin\SystemSetController@setSort');
    Route::post('delMenu', 'Admin\SystemSetController@delMenu');

    //用户列表接口
    Route::post('getUserList', 'Admin\UserController@getList');
    Route::post('addUser', 'Admin\UserController@add');
    Route::post('editUser', 'Admin\UserController@edit');
    //启用禁用用户
    Route::post('editUserStatus', 'Admin\UserController@editStatus');


    //用户组接口 addGroup
    Route::post('getGroupList', 'Admin\GroupController@getList');
    Route::post('saveGroupUsers', 'Admin\GroupController@saveGroupUsers');
    //删除用户组
    Route::post('delGroup', 'Admin\GroupController@delGroup');
    Route::post('addGroup', 'Admin\GroupController@addGroup');
    Route::post('editGroup', 'Admin\GroupController@editGroup');


});
